<template>
	<image src="/static/image/09.png" mode="widthFix" class="bg"></image>
	<u-navbar
	title="收益"
	:autoBack="true"
	:background="{
	background:'#E40417'
	}"
	:border-bottom="false"
	titleSize="28rpx" titleColor="#fff"
	back-icon-color="#fff"
	/>
	
	<view class="container pl30 pr30">
		
		<view class="header t-flex colum bgf r20 mt30">
			<view class="f26 c9 mb20">
				累计收益（元）
			</view>
			<view class="f36 mainC prc bold">
				+{{$str.money(statistics.total_sy)}}
			</view>
			<view class="f26 mt30">
				<text class="c9">本月收益（元）：</text>
				<text class="f30 prc bold">+{{$str.money(statistics.by_sy)}}</text>
			</view>
		</view>
		
		<view class="bgf r20 p30 mt20">
			<view class="t-flex between mb30" @click="$go('/pages/workerClient/earnings/log')">
				<view class="f32 c3 bold">
					历史月收益
				</view>
				<text class="iconfont icon-xiangyou1 c9"></text>
			</view>
			
			<view class="t-flex between">
				<view class="block t-flex colum center r10">
					<view class="f26 c9">
						订单收益
					</view>
					<view class="f30 c3 mt10 bold">
						￥{{$str.money(statistics.order_sy)}}
					</view>
				</view>
				<view class="block t-flex colum center r10">
					<view class="f26 c9">
						佣金收益
					</view>
					<view class="f30 c3 mt10 bold">
						￥{{$str.money(statistics.yj_sy)}}
					</view>
				</view>
			</view>
			
		</view>
		
		
		<view class="log bgf r20 mt20" v-for="item in data" :key="item.id">
			<view class="mb10 " :class="item.type==1?'or':'ge'">
				{{item.type==1?'订单分佣':'订单收益'}}
			</view>
			<view class="t-flex between">
				<view class="f30 c3 bold">
					{{item.order_sn}}
				</view>
				<view class="bold mainC">
					￥{{item.price}}
				</view>
			</view>
			
			<view class="f24 c9 mt10">
				{{item.nickname}}（{{item.mobile}}）/{{item.car_type}}（1小时）
			</view>
		</view>
		<empty msg='本月暂无记录' v-if="data.length === 0"></empty>
		
		<view class="bpad"></view>
		
		
	</view>
	
	
	
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { onShow,onLoad,onPullDownRefresh,onReachBottom } from "@dcloudio/uni-app"
import { sfShouyi } from '../../../api';
import { getTime, usePaging } from '../../../lib/ts/util';
	
	
	let statistics = ref()
	let {
		data,
		reload,
		getMore
	} = usePaging('/api/master/GetSfList',{key:'info'})
	
	
	onShow(()=>{
		getdata()
	})
	onLoad(()=>{
		reload({
			month:getTime(+new Date()/1000,6),
		})
	})
	onPullDownRefresh(()=>{
		getdata()
		reload({
			month:getTime(+new Date()/1000,6),
		})
	})
	onReachBottom(()=>{
		getMore({
			month:getTime(+new Date()/1000,6),
		})
	})
	
	const getdata = async ()=>{
		statistics.value = await sfShouyi()
	}
	

</script>

<style scoped lang="scss">
	.bg{
		width: 100%;
		position: fixed;
	}
	
	.container{
		position: relative;
		z-index: 2;
	}
	
	.header{
		padding: 50rpx 0;
		.prc{
			&::first-letter{
				font-size: 26rpx;
			}
		}
	}
	.block{
		width: 298rpx;
		height: 126rpx;
		background: #F5F6F8;
	}
	
	.log{
		padding: 26rpx 30rpx;
	}
	.ge{
		color: #16D46B;
	}
	.or{
		color: orange;
	}
	
	
</style>
